package com.cryptoneedle.center.config.controller;

import com.bubbles.engine.common.core.result.Result;
import com.cryptoneedle.center.config.entity.ConfigSsh;
import com.cryptoneedle.center.config.service.ConfigSshService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>description: 配置SSH 控制器 </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-26
 */
@Tag(name = "配置SSH", description = "配置SSH")
@RestController
@RequestMapping("/config/ssh")
public class ConfigSshController {

    @Resource
    private ConfigSshService configSshService;

    @PostMapping("/host/list")
    public Result<List<String>> listHost() {
        return Result.success(configSshService.listHost());
    }

    @PostMapping("/{host}")
    public Result<ConfigSsh> getByHost(@PathVariable("host") String host) {
        return Result.success(configSshService.getById(host));
    }

    @PostMapping("/save")
    public Result<?> save(@RequestBody ConfigSsh configSsh) {
        configSshService.save(configSsh);
        return Result.success();
    }
}